home *** CD-ROM | disk | FTP | other *** search
/ ftp.whtech.com / ftp.whtech.com.tar / ftp.whtech.com / datasheets and manuals / Hardware / WHT / scsi / dsr_sources_2_2001 / rmdir < prev    next >
Text File  |  2006-10-19  |  5KB  |  193 lines

  1. ************************************************************
  2. *                                                          *
  3. *  GPL Subprogram >29 - Delete Subdirectory                *
  4. *                                                          *
  5. *  Date: January 12, 1996                                  *
  6. *  Author: David Nieters                                   *
  7. *                                                          *
  8. *  Description:  This subroutine will delete a             *
  9. *    subdirectory, but only if it is empty.                *
  10. *                                                          *
  11. *  Inputs:                                                 *
  12. *     PATH - Contains parent directory (blank if in root)  *
  13. *     >834C - Unit Number                                  *
  14. *     >834E - Pointer to directory name                    *
  15. *                                                          *
  16. *  Error Codes:                                            *
  17. *     4 - Directory was not empty                          *
  18. *     6 - Device Error                                     *
  19. *     7 - Directory does not exist                         *
  20. *                                                          *
  21. *  Modifications:                                          *
  22. *     March 22, 1997 - Added code to delete FDIR also when *
  23. *                      deleting a directory                *
  24. *                                                          *
  25. ************************************************************
  26.  
  27. RMDIR0 ANDI R12,>FF00
  28.        AI   R12,24
  29.  
  30.        BL   @MAKEFN
  31.  
  32. * Append a period to the name
  33. *
  34.        LDCR @B02,4
  35.        LI   R1,NCB
  36. RMDIR1 CB   *R1+,@SPACE
  37.        JNE  RMDIR1
  38.        DEC  R1
  39.        MOVB @PERIOD,*R1
  40.        LDCR @B04,4
  41.        MOVB @PERIOD,*R1
  42.  
  43. * See if the directory exists
  44. *
  45.        BL   @GETDDR
  46.        CI   R5,0
  47.        JNE  RMDIR2           Directory does not exist
  48.        MOVB @B07,@>8350      Set error code
  49.        B    @DSRRT
  50.  
  51. * Directory exists - make sure it is empty
  52. *
  53. RMDIR2 LDCR @B03,4
  54.        C    @22(R5),@ZERO
  55.        JEQ  RMDIR3
  56.        MOVB @B04,@>8350      Set error code
  57.        B    @DSRRT
  58.  
  59. * Directory exists and is empty - delete it
  60. * Step 1: Remove the AU from the parent and decrement
  61. *         the number of subdirectories counter
  62. * Step 2: Deallocate the AU formerly used by the deleted DDR
  63. * Step 3: Deallocate the AU of the FDIR
  64. *
  65.  
  66. RMDIR3
  67.        MOV  @24(R5),R1   Get AU of FDIR
  68.        LDCR @B02,4
  69.        MOV  R1,@MKDAU2   And save for later
  70.  
  71. * We should invalidate the cache entry.  Something like this
  72. * should do it -
  73. *
  74.        LDCR @B04,4
  75.        CLR  *R4
  76.  
  77. *      LDCR @B04,4
  78.        MOV  @SAVEAU,R1       Get AU of DDR
  79.        LDCR @B02,4
  80.        MOV  R1,@SFDRAU       Save for later
  81.  
  82. * Remove the last period from the file name and get the
  83. * parent DDR
  84. *
  85.  
  86.        LDCR @B02,4
  87.        LI   R1,NCB+39
  88. RMDIR4 CB   *R1,@PERIOD
  89.        JEQ  RMDIR5
  90.        DEC  R1
  91.        JMP  RMDIR4
  92.  
  93. RMDIR5 MOVB @SPACE,*R1
  94.        LDCR @B04,4
  95.        MOVB @SPACE,*R1
  96.  
  97.        BL   @GETDDR
  98.        LDCR @B02,4
  99.        MOV  @SFDRAU,R7
  100.        LDCR @B03,4
  101.  
  102.        SB   @B01,@23(R5)     Decrement subdirectory counter
  103.        MOV  R5,R4
  104.        AI   R4,28
  105. RMDIR6 C    R7,*R4+
  106.        JNE  RMDIR6
  107.  
  108.        AI   R5,256           Now points to end of DDR
  109.        MOV  R4,R3
  110.        DECT R3
  111. RMDIR7 MOV  *R4+,*R3+
  112.        C    R4,R5
  113.        JNE  RMDIR7
  114.        CLR  *R3
  115.        AI   R5,-256
  116.  
  117. * Now write DDR back out
  118. *
  119.        LDCR @B04,4
  120.        MOV  @SAVEAU,R7       Get AU of parent DDR
  121.        MOV  R6,R3
  122.        SRL  R3,8
  123.        SLA  R3,1
  124.        MPY  @SAUTBL(R3),R7
  125.  
  126.        LI   R1,SECBUF
  127.        SRL  R8,1
  128.        JNC  RMDR7A
  129.        AI   R1,>100
  130. RMDR7A SRL  R7,1
  131.        JNC  RMDR7B
  132.        AI   R8,>8000
  133. RMDR7B
  134.        LDCR @ZERO,4
  135.        BLWP @BANKIT
  136.        DATA SCSIRD
  137.        JEQ  RMDIR8
  138.  
  139. RMDIRE MOVB @B06,@>8350
  140.        B    @DSRRT
  141.  
  142. RMDIR8
  143. * Copy the new DDR and write it back out
  144. *
  145.        LI   R0,256
  146. RMDR8A LDCR @B03,4
  147.        MOV  *R5+,R2
  148.        LDCR @ZERO,4
  149.        MOV  R2,*R1+
  150.        DECT R0
  151.        JNE  RMDR8A
  152.  
  153.        BLWP @BANKIT
  154.        DATA SCSIWT
  155.        JNE  RMDIRE
  156.  
  157. * If we are writing out the VIB, we need to write
  158. * out the copy as well
  159.  
  160.        CI   R7,0
  161.        JNE  RMDIR9
  162.        CI   R8,0
  163.        JNE  RMDIR9
  164.        AI   R8,16
  165.        BLWP @BANKIT
  166.        DATA SCSIWT
  167.        JNE  RMDIRE
  168. RMDIR9
  169. * Now deallocate the AU.  If the DDR and FDIR are adjacent, we can
  170. * delallocate both AUs in one call.  Otherwise, we have to make two
  171. * calls to DEALL.
  172.  
  173.        LDCR @B02,4
  174.        MOV  @SFDRAU,R7
  175.        MOV  @MKDAU2,R8
  176.        MOV  R8,R1
  177.        DEC  R1
  178.        C    R1,R7
  179.        JEQ  RMDR9A
  180.  
  181.        MOV  R7,R8
  182.        LDCR @ZERO,4
  183.        BLWP @DEALL
  184.  
  185.        LDCR @B02,4
  186.        MOV  @MKDAU2,R7
  187.        MOV  R7,R8
  188. RMDR9A LDCR @ZERO,4
  189.        BLWP @DEALL
  190.  
  191.        MOVB @ZERO,@>8350     Set success code
  192.        B    @DSRRT
  193.